package com.kaifamiao.www.demo.do0815;

import java.util.Comparator;
import java.util.TreeMap;

public class TreeMapDemo {
    public static  void main(String[] args) {

        Comparator Comparator = new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getAge() - o2.getAge();
            }
        };
        TreeMap treeMap = new TreeMap(Comparator);
//        TreeMap treeMap = new TreeMap();
//        treeMap.put(5,"a");
//        treeMap.put(8,"c");
//        treeMap.put(1,"q");
        treeMap.put(new Student("鸡坤",30),"z");
        treeMap.put(new Student("慢羊羊", 35), "C");
        treeMap.put(new Student("喜羊羊", 19), "A");
        treeMap.put(new Student("灰太狼", 31), "B");
        System.out.println(treeMap);
        System.out.println(treeMap.firstKey());
        System.out.println(treeMap.firstEntry());

    }
}
